package qianzhuihe;

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        //先输入数据
        int n = in.nextInt();
        int m = in.nextInt();
        int q = in.nextInt();
        int[][] arr = new int[n+1][m+1];
        for(int i = 1;i <= n;i++) {
            for(int j = 1;j <= m; j++) {
                arr[i][j] = in.nextInt();
            }
        }
        long[][] sumDp = new long[n+1][m+1];
        for(int i = 1;i<=n;i++) {
            for(int j = 1;j<=m;j++) {
                sumDp[i][j] = sumDp[i -1][j] + sumDp[i][j-1] + arr[i][j] - sumDp[i-1][j-1]; //dp数组的公式
            }
        }

        //使用该前缀和Dp数组
        while(q > 0) {
            //输入必须得是先x1,y1  再x2,y2  不然就报错
            int x1 = in.nextInt(), y1 = in.nextInt(), x2 = in.nextInt(), y2 = in.nextInt();
            System.out.println(sumDp[x2][y2] - sumDp[x1 - 1][y2] - sumDp[x2][y1 - 1] + sumDp[x1 - 1][y1 - 1]);
            q--;
        }
    }
}
